﻿using Omabar.BLL;
using Omabar.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Omabar.CMS.Pages
{
    public partial class Index : System.Web.UI.Page
    {
        #region 旧的不用的
        //protected List<ROUTE> orginRoutes;  //独创  ROUTE_ORIGINAL=1
        //protected List<ROUTE> qualityRoutes;    //品质 ROUTE_ELABORATE=1
        //protected List<ROUTE> hotestRoutes; //顶部图片  ROUTE_HOT>90
        //protected List<ROUTE_SPECIALITEM> rss;
        //protected SpecialItem_BLL spBLL;
        //protected Route_SpecialItem_BLL routeSPBLL;
        #endregion

        protected USER user;
        protected List<SLIDER> tSliders;
        protected List<SLIDER> spiSliders;
        protected List<SLIDER> orginSliders;
        protected List<Tailor> tailors;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    user = Context.Session["CURRENTUSER"] as USER;

                    #region 旧的不用的
                    /*
                Route_BLL bll = new Route_BLL();
                
                string orginSQL = "select Top 10 ROUTE_ID,ROUTE_NAME,ROUTE_DES,ROUTE_CHENGDU,ROUTE_BEIJING,ROUTE_ELSECITY,ROUTE_CHARACTERISTIC,ROUTE_DAYS,ROUTE_PRICE,ROUTE_DATE_START,ROUTE_DATE_END,ROUTE_HOT,ROUTE_BAK,ROUTE_ELABORATE,ROUTE_ORIGINAL from (select row_number() over(order by ROUTE_HOT desc) as rownumber,* from ROUTE WHERE ROUTE_ORIGINAL=1) A where rownumber > 0";

                orginRoutes = bll.GetModels(orginSQL);
                if (orginRoutes == null) orginRoutes = new List<ROUTE>();

                string qualitySQL = "select Top 6 ROUTE_ID,ROUTE_NAME,ROUTE_DES,ROUTE_CHENGDU,ROUTE_BEIJING,ROUTE_ELSECITY,ROUTE_CHARACTERISTIC,ROUTE_DAYS,ROUTE_PRICE,ROUTE_DATE_START,ROUTE_DATE_END,ROUTE_HOT,ROUTE_BAK,ROUTE_ELABORATE,ROUTE_ORIGINAL FROM ROUTE WHERE ROUTE_ELABORATE=1 ORDER BY ROUTE_HOT DESC";
                qualityRoutes = bll.GetModels(qualitySQL);
                if (qualityRoutes == null) qualityRoutes = new List<ROUTE>();

                string hotestSQL = "select Top 5 ROUTE_ID,ROUTE_NAME,ROUTE_DES,ROUTE_CHENGDU,ROUTE_BEIJING,ROUTE_ELSECITY,ROUTE_CHARACTERISTIC,ROUTE_DAYS,ROUTE_PRICE,ROUTE_DATE_START,ROUTE_DATE_END,ROUTE_HOT,ROUTE_BAK,ROUTE_ELABORATE,ROUTE_ORIGINAL FROM ROUTE WHERE ROUTE_HOT>90 ORDER BY ROUTE_HOT DESC";
                hotestRoutes = bll.GetModels(hotestSQL);
                if (hotestRoutes == null) hotestRoutes = new List<ROUTE>();

                spBLL = new SpecialItem_BLL();
                routeSPBLL = new Route_SpecialItem_BLL();
                rss = routeSPBLL.GetModels("select Top 20 ROUTE_ID,SPECIALITEM_ID from ROUTE_SPECIALITEM where ROUTE_ID in (select ROUTE_ID from ROUTE)");
                if (rss == null) rss = new List<ROUTE_SPECIALITEM>();
                */
                    #endregion

                    Slider_BLL sliderBLL = new Slider_BLL();
                    //原创
                    string orginSQL = "SELECT Top 10 SLIDER_ID,SLIDER_IMAGE,SLIDER_URL,SLIDER_DES,SLIDER_SORT,SLIDER_TYPE,SLIDER_BAK FROM SLIDER WHERE SLIDER_TYPE=1 order by  SLIDER_SORT";
                    orginSliders = sliderBLL.GetModels(orginSQL);
                    if (orginSliders == null) orginSliders = new List<SLIDER>();
                    //T图
                    string tSQL = "SELECT Top 10 SLIDER_ID,SLIDER_IMAGE,SLIDER_URL,SLIDER_DES,SLIDER_SORT,SLIDER_TYPE,SLIDER_BAK FROM SLIDER WHERE SLIDER_TYPE=0 order by  SLIDER_SORT ";
                    tSliders = sliderBLL.GetModels(tSQL);
                    if (tSliders == null) tSliders = new List<SLIDER>();
                    //特色项目
                    string spiSQL = "SELECT  SLIDER_ID,SLIDER_IMAGE,SLIDER_URL,SLIDER_DES,SLIDER_SORT,SLIDER_TYPE,SLIDER_BAK FROM SLIDER WHERE SLIDER_TYPE=2 order by  SLIDER_SORT";
                    spiSliders = sliderBLL.GetModels(spiSQL);
                    if (spiSliders == null) spiSliders = new List<SLIDER>();
                    //定制师
                    Tailor_BLL tailor_BLL = new Tailor_BLL();
                    tailors = tailor_BLL.GetModels("select TOP 3 TAILOR_ID , TAILOR_NAME,TAILOR_INFO,TAILOR_SPECIALTY,TAILOR_CASE,TAILOR_QQ,TAILOR_PHONE,TAILOR_HEAD_IMG,TAILOR_HOT   FROM TAILOR ORDER BY TAILOR_HOT DESC");
                    if (tailors == null) tailors = new List<Tailor>();
                }
            }
            catch (Exception ex)
            {
                Tom.Net.Log.LogManager.Error("Index页面错误", ex);
            }
        }
    }
}